--祈福
---@class Billboard_BlessPanel : UIComponentBase
local BlessPanel = Class("BlessPanel",UIComponentBase)
local t = BlessPanel

function t:OnCreate()
    self.dayTxt = self:GetChild("day")
    self.monthTxt = self:GetChild("month")
    self.holidayTxt = self:GetChild("holiday")
    self.holidayTitle = self:GetChild("HolidayTitle")
    self.blessResultTxt = self:GetChild("BlessResult")
    self.btnBlessBtn = self:GetChild("BlessBtn")
    self.banner = self:GetChild("banner")
    self.ctrlBless = self:GetController("ctrlBless")
    self:RegisterOnClick(self.btnBlessBtn,self.ClickBless)
    self:RegisterEvent(Config.EventType.RefreshNoticeBless,self.RefreshNoticeBless)
end

function t:OnEnable()
    self:Refresh()
end
function t:OnDisable()
end
function t:OnDestroy()
end
function t:Refresh()
    local time = HelperFunc.GetServerTime()
    local month = os.date("%m",time)
    local day = os.date("%d",time)
    local w = os.date("%w",time)
    self.dayTxt.text = day
    self.monthTxt.text = month
    local dayCfg = logicMgr.NoticeManager.GetTodayBuffCfg()
    local str = getLanguage(dayCfg.f_Dayname)
    self.holidayTitle.text = str
    self.holidayTxt.text = getLanguage("DayNameKey"..(w+1))
    self.banner.url = "ui://UIBillBoards/"..dayCfg.f_DayBanner
    --buff
    if logicMgr.NoticeManager.buffId > 0 then
        local cfg = G.dataTable["t_ecobuff"][tostring(logicMgr.NoticeManager.buffId)]--dataTable.getDataTableByStringId("t_skill",buffId)
        if cfg then
            self.blessResultTxt.text = getLanguage(cfg.f_BuffDesc)
        end
        self.ctrlBless.selectedIndex = 0
    else
        self.blessResultTxt.text = ""
        self.ctrlBless.selectedIndex = 1
    end
end
function t:RefreshNoticeBless()
    self:Refresh()
end
function t:ClickBless()
    if logicMgr.NoticeManager.buffId > 0 then
        return
    end
    --NoticeHandler.ReqRankWish()
end
return t